#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    int n;
    cin >> n;
    vector<int> pre1(n + 1), pre2(n + 1);
    vector<int> a(n + 1);
    for(int i = 1; i  <= n; i++) cin >> a[i]; 
    int ans[2];
    ans[0] = 0, ans[1] = 0;
    string s; cin >> s;
    for(int i = 1 ;i <= n; i++) {
        if(s[i - 1] == '1') {
            pre2[i] = pre2[i - 1] ^ a[i];
            pre1[i] = pre1[i - 1];
            ans[1] ^= a[i];
        }
        else {
            pre2[i] = pre2[i - 1];
            pre1[i] = pre1[i - 1] ^ a[i];
            ans[0] ^= a[i];
        }
    }
    int q;
    cin >> q;
    while(q--) {
        int op;
        cin >> op;
        if(op == 2) {
            int x; cin >> x;
            cout << ans[x] << ' ';
        }else{
            int l, r;
            cin >> l >> r;
            ans[0] ^= (pre1[r] ^ pre1[l - 1] ^ pre2[r] ^ pre2[l - 1]);
            ans[1] ^= (pre1[r] ^ pre1[l - 1] ^ pre2[r] ^ pre2[l - 1]);
        }
    }
    cout << endl;
}

signed main() {
    int t; cin >> t;
    while(t--) solve();
    return 0;
}
